package gocmd

import (
	"fmt"
	enc "gitee.com/ichub/goconfig/cmd/goconfig/cmdenc"
	"gitee.com/ichub/goconfig/cmd/goconfig/gomenu"
	"gitee.com/ichub/goconfig/common/ichubconfig"
	"github.com/sirupsen/logrus"
	"github.com/spf13/cobra"
)

var cfgCmd = &cobra.Command{
	Use:   "list",
	Short: "list config of project",
	Run: func(cmd *cobra.Command, args []string) {
		fmt.Println("view config")
		var cfg = ichubconfig.FindBeanIchubConfig()

		logrus.Info(cfg.Read().ToPrettyString())
	},
}

func init() {

	var gomenuFactroy = gomenu.FindBeanGomenuFactroy()
	gomenuFactroy.SetVersion("1.0")
	gomenuFactroy.SetCmdName("goconfig")
	gomenuFactroy.SetBasePkg("gitee.com/ichub/goconfig/cmd/goconfig/gomenu")
	gomenuFactroy.Init()
	gomenuFactroy.AddCommands(enc.EncCmds()...)
	gomenuFactroy.AddCommand(cfgCmd)

}

func Execute() {
	gomenu.FindBeanGomenuFactroy().Execute()
}
